#include<stdio.h>
struct Student
{
  char id[20];
  char name[20];
  double math;
  double english;
  double total;
};
int main(){
  struct Student stu1[10];
  struct Student stu2[10];
  int j = 0;
  FILE *pfwrite = fopen("student.txt","wb");
  for(int i=0;i<10;i++)
  {
    gets(stu1[i].name);
    gets(stu1[i].id);
    scanf("%lf",&stu1[i].math);
    scanf("%lf",&stu1[i].english);
    getchar();
    stu1[i].total = stu1[i].math+stu1[i].english;
  }
  //   for(int i=0;i<10;i++)
  // {
  //   printf("name:%s\nid:%s\ntotal:%.2lf\n",stu1[i].name,stu1[i].id,stu1[i].total);
  // }
  for(int i=0;i<10;i++)
  {
    fwrite((stu1+i),sizeof(struct Student),1,pfwrite);
  }
  fclose(pfwrite);
  pfwrite = NULL;
  FILE *pfread = fopen("student.txt","rb");
  struct Student stu;
  while(fread(&stu,sizeof(struct Student),1,pfread))
  {
    stu2[j] = stu;
    j++;
  }
  for(int i=0;i<10;i++)
  {
    printf("name:%s\nid:%s\ntotal:%.2lf",stu2[i].name,stu2[i].id,stu2[i].total);
  }
  fclose(pfread);
  pfread = NULL;
  return 0;
}